# admin_interface.py
from services import ATMService
from repository import UserRepository
from admin import Admin

class AdminInterface:
    def __init__(self):
        self.repository = UserRepository()
        self.service = ATMService(self.repository)

    def start(self):
        Admin.print_admin_view()
        if Admin.authenticate():
            print("管理员登录成功")
            self.show_menu()
        else:
            print("管理员登录失败")

    def show_menu(self):
        Admin.print_func_view()
        while True:
            choice = input("请选择操作：")
            if choice == "1":
                self.handle_create_account()
            elif choice == "2":
                self.handle_cancel_account()
            elif choice.upper() == "Q":
                print("退出管理员界面！")
                break

    def handle_create_account(self):
        name = input("请输入姓名: ")
        user_id = input("请输入身份证号: ")
        phone = input("请输入手机号: ")
        prest_money = float(input("请输入预存金额: "))
        password = input("请输入密码: ")
        print(self.service.create_user(name, user_id, phone, prest_money, password))

    def handle_cancel_account(self):
        card_id = input("请输入要注销的卡号: ")
        print(self.service.cancel_account(card_id))
